<template>
	<view>
		<view class="goods-list">
			<view v-for="(goods,i) in goodsList" :key="i" @click="gotoDetail(goods)">
				<my-goods :goods="goods"></my-goods>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				queryObj:{
					data_copyfrom:'',
					cat_name:'',
					pagenum:1,
					pagesize:10
				},
				goodsList:[],
				total:0
			};
		},
			
		onLoad(options){
			this.queryObj.data_copyfrom=options.data_copyfrom || ''
			this.queryObj.cat_name=options.cat_name || ''
			 
			this.getGoodsList()
		},
		methods:{
			async getGoodsList(cb){
				const { data: res }=await uni.$http.post('http://127.0.0.1:5000/goodlist',this.queryObj)
				if(res.meta.status !== 200)return uni.$showMsg()	
							
				cb && cb()
				this.goodsList=res.message[0].goods
				this.total=res.message[0].total
			},
			gotoDetail(goods){
				uni.navigateTo({
					url:'/subpkg/goods_detail/goods_detail?data_title='+goods.data_title
				})
			}
		},
		onPullDownRefresh(){
			// this.isloading=false
			this.goodsList=[]
			
			this.getGoodsList(()=> uni.stopPullDownRefresh())
		}
	}
</script>

<style lang="scss">

</style>
